<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <table>
        <tr>
            <td><input type="number" id="num"></td>
            <td><button onclick="clickMe()">阶乘</button></td>
            <td>=</td>
            <td><span id="spanId">???</span></td>
        </tr>
    </table>
    <script type="text/javascript">
        function clickMe(){
            var spanObj =document.getElementById('spanId')
            var num = document.getElementById('num');
            num = parseInt(num.value);
            for (let i = num - 1; i > 0; i--) {
                num = num * i;
            }
            spanObj.innerHTML =num;
        }
    </script>
</body>
</html>